<template>
	<view>
		<view class="box">
			<view>
				<input class="width84 card" v-model="card" type="idcard" :placeholder="tipMessage" maxlength="18" />
			</view>
			<view class="tip_message">
				⬆⬆⬆{{tipMessage}}
			</view>
			<view class="width84">
				<button @click="submit()">确认</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1,
				card: "",
				tipMessage: "请输入身份信息进行充值" //未查询到该住院号信息
			}
		},
		onLoad(option) {
			if (option.type) {
				this.init(option.type);
			}

		},
		methods: {
			init(type) {
				//信息初始化
				this.type = type;
			},
			submit() {
				let params = {
					"kh0000": this.card,
					"ywlsh0": "" + new Date().getTime(),
					"funid": "F07.02.02.02"
				};
				//数据提交判断
				let patrn =
					/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
				if (patrn.test(this.card)) {
					params.klx000 = "3";
					this.searchInfo(params);
				} else {
					params.klx000 = "4";
					this.searchInfo(params);
				}
			},
			searchInfo(params) {
				uni.showLoading({
					mask: true,
					title: "查询中..."
				});
				this.$postJson("/qnyesb/qnyesbproxy", params, res => {
					if (res.state == 0) {
						uni.navigateTo({
							url: "hospitalizedPay?user=" + JSON.stringify(res.data.retrieve[0])
						})
					} else {
						uni.showToast({
							title: res.message,
							icon: "none",
							duration: 5000
						})
					}
					uni.hideLoading();
				})
			}
		}
	}
</script>

<style>
	.box {
		width: 96%;
		height: 170px;
		margin: 0 auto;
		background: #FFFFFF;
		margin-top: 10px;
		padding-top: 21px;
	}

	.box .card {
		height: 39px;
		border: 1px solid #e6e6e6;
		border-radius: 32px;
		text-indent: 1em;
	}

	.box .tip_message {
		text-align: center;
		font-size: 12px;
		font-family: Source Han Sans CN;
		font-weight: 400;
		line-height: 40px;
		color: #ff0000;

	}

	.width84 button {
		background: #3692FF;
		color: #ffffff;
	}
</style>
